#include <iostream>
#include "d_Math.h"

using namespace d_Math;

d_Vec2f::d_Vec2f()
{
	p[0] = p[1] = 0;
}

d_Vec2f::d_Vec2f(const d_Vec2f &v)
{
	p[0] = v[0];
	p[1] = v[1];
}

d_Vec2f::d_Vec2f(float x, float y)
{
	p[0] = x;
	p[1] = y;
}

float &d_Vec2f::operator [] (int i)
{
	if(i>2)
	{
		std::cout << "Bad index for vector!" << std::endl;
		return p[0];
	}
	return p[i];
}

float d_Vec2f::operator [] (int i) const
{
	if(i>2)
	{
		std::cout << "Bad index for vector!" << std::endl;
		return p[0];
	}
	return p[i];
}

d_Vec2f d_Vec2f::operator + (const d_Vec2f v) const
{
	d_Vec2f res(p[0]+v[0], p[1]+v[1]);
	return res;
}

d_Vec2f d_Vec2f::operator - (const d_Vec2f v) const
{
	d_Vec2f res(p[0]-v[0], p[1]-v[1]);
	return res;
}

d_Vec2f d_Vec2f::operator * (const float a) const
{
	d_Vec2f res(p[0]*a, p[1]*a);
	return res;
}

d_Vec2f d_Vec2f::operator / (const float a) const
{
	d_Vec2f res(p[0]/a, p[1]/a);
	return res;
}

